home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************
- *
- * Project Name: FTTools
- * File Name: fdef.c
- * Author: Rob Neville (IIx)
- * Date: May 17, 1989
- *
- * Description: Template fdef function.
- *
- *************************************************************************************
- *
- * Revision History:
- * 5/17/89 - Original version by Rob Neville (IIx)
- *
- ************************************************************************************/
-
- #include "FTTool.h"
-
- pascal long FDEF(hTH,msg,p1,p2,p3)
- ToolHandle hTH;
- short msg;
- long p1,p2,p3;
- {
- long theErr;
- long ToolInit(ToolHandle);
- long ToolDispose(ToolHandle);
- long ToolSuspend(ToolHandle);
- long ToolResume(ToolHandle);
- long ToolMenu(ToolHandle,short,short);
- long ToolEvent(ToolHandle,EventRecord *);
- long ToolActivate(ToolHandle);
- long ToolDeactivate(ToolHandle);
- long ToolAbort(ToolHandle);
- long ToolStart(ToolHandle,short,SFReply *);
- long ToolExec(ToolHandle);
-
- switch (msg)
- {
- case InitMsg:
- theErr = ToolInit(hTH); /* below */
- break;
- case DisposeMsg:
- theErr = ToolDispose(hTH); /* below */
- break;
- case SuspendMsg:
- theErr = ToolSuspend(hTH); /* below */
- break;
- case ResumeMsg:
- theErr = ToolResume(hTH); /* below */
- break;
- case MenuMsg:
- theErr = ToolMenu(hTH,(short)p1,(short)p2); /* below */
- break;
- case EventMsg:
- theErr = ToolEvent(hTH,(EventRecord *)p1); /* below */
- break;
- case ActivateMsg:
- theErr = ToolActivate(hTH); /* below */
- break;
- case DeactivateMsg:
- theErr = ToolDeactivate(hTH); /* below */
- break;
- case AbortMsg:
- theErr = ToolAbort(hTH); /* below */
- break;
- case StartMsg:
- theErr = ToolStart(hTH,(short)p1,(SFReply *)p2); /* below */
- break;
- case ExecMsg:
- theErr = ToolExec(hTH); /* below */
- break;
- default: /* we should never get this */
- theErr = NotSupported; /* I don't support unsupported messages */
- break;
- }
- return (theErr);
- #pragma unused (p3)
- }
-
- long ToolInit(ToolHandle hTH)
- {
- PrivatePtr private;
- Str255 autoName = "tallyho";
-
- if ((**hTH).procID < 3)
- {
- DebugStr("\pPipe is blocked!!! Call New!!;hc;g");
- (**hTH).errCode = Failed;
- return (Failed);
- }
- private = (PrivatePtr)NewPtrClear(sizeof(Private));
- if (private == nil)
- {
- (**hTH).errCode = OutOfMemory;
- return (OutOfMemory);
- }
- else
- (**hTH).ftPrivate = (Ptr)private;
- (**hTH).autoRec[0] = strlen(autoName);
- strcpy(&(**hTH).autoRec[1],autoName);
- return (NoErr);
- }
-
- long ToolDispose(ToolHandle hTH)
- {
- if ((**hTH).procID < 3)
- {
- DebugStr("\pPipe is blocked!!! Call Dispose!!;hc;g");
- (**hTH).errCode = Failed;
- return (Failed);
- }
- DisposPtr((**hTH).ftPrivate); /* dispose my only data structure */
- return (NoErr);
- }
-
- long ToolSuspend(ToolHandle hTH)
- {
- if ( ( (**hTH).procID < 3) || ( (**hTH).ftPrivate == nil ) ) /* not a valid hTH */
- {
- DebugStr("\pPipe is blocked!!! Call Suspend!!;hc;g");
- return (Failed);
- }
- return (NoErr);
- }
-
- long ToolResume(ToolHandle hTH)
- {
- if ( ( (**hTH).procID < 3) || ( (**hTH).ftPrivate == nil ) ) /* not a valid hTH */
- {
- DebugStr("\pPipe is blocked!!! Call Resume!!;hc;g");
- return (Failed);
- }
- return (NoErr);
- }
-
- long ToolMenu(ToolHandle hTH,short p1,short p2)
- {
- if ( ( (**hTH).procID < 3 ) || ( (**hTH).ftPrivate == nil ) ) /* not a valid hTH */
- {
- DebugStr("\pPipe is blocked!!! Call Menu!! In Handle;hc;g");
- (**hTH).errCode = Failed;
- return (Failed);
- }
- if (p1 >= 32767 || p1 <= -32768)
- {
- DebugStr("\pPipe is blocked!!! Call Menu!! Invalid p1;hc;g");
- (**hTH).errCode = Failed;
- return (Failed);
- }
- if (p2 >= 32767 || p2 <= -32768)
- {
- DebugStr("\pPipe is blocked!!! Call Menu!! Invalid p2;hc;g");
- (**hTH).errCode = Failed;
- return (Failed);
- }
- return (NoErr);
- }
-
- long ToolEvent(ToolHandle hTH,EventRecord *theEvent) /* Don't pass this a NullEvent PLEASE */
- ToolHandle hTH;
- {
- if ( ((**hTH).procID < 3) || ((**hTH).ftPrivate == nil) ) /* not a valid hTH and what is empty */
- {
- DebugStr("\pPipe is blocked!!! Call Event!! In Handle;hc;g");
- return (Failed);
- }
- if (theEvent->what == 0 )
- {
- DebugStr("\pPipe is blocked!!! Call Event!! p1;hc;g");
- return (Failed);
- }
- return (NoErr);
- }
-
- long ToolActivate(ToolHandle hTH)
- {
- if ( ( (**hTH).procID < 3 ) || ( (**hTH).ftPrivate == nil ) ) /* not a valid hTH */
- {
- DebugStr("\pPipe is blocked!!! Call Activate!!;hc;g");
- return (Failed);
- }
- return (NoErr);
- }
-
- long ToolDeactivate(ToolHandle hTH)
- {
- if ( ( (**hTH).procID < 3 ) || ( (**hTH).ftPrivate == nil ) ) /* not a valid hTH */
- {
- DebugStr("\pPipe is blocked!!! Call Deactivate!!;hc;g");
- return (Failed);
- }
- return (NoErr);
- }
-
- long ToolAbort(ToolHandle hTH)
- {
- if ( ( (**hTH).procID < 3 ) || ( (**hTH).ftPrivate == nil ) ) /* not a valid hTH */
- {
- DebugStr("\pPipe is blocked!!! Call Abort!!;hc;g");
- return (Failed);
- }
- return (NoErr);
- }
-
- long ToolStart(ToolHandle hTH,short p1,SFReply *p2)
- {
- if ( ( (**hTH).procID < 3 ) || ( (**hTH).ftPrivate == nil ) ) /* not a valid hTH */
- {
- DebugStr("\pPipe is blocked!!! Call Start!! In Handle;hc;g");
- return (Failed);
- }
- if (p1 < 0)
- {
- DebugStr("\pPipe is blocked!!! Call Start!! In p1;hc;g");
- return (Failed);
- }
- if (p2 < 0)
- {
- DebugStr("\pPipe is blocked!!! Call Start!! In p2;hc;g");
- return (Failed);
- }
- return (NoErr);
- }
-
- long ToolExec(ToolHandle hTH)
- {
- long result = NoErr;
-
- if ( ( (**hTH).procID < 3 ) || ( (**hTH).config == nil ) ) /* not a valid hTH */
- {
- DebugStr("\pPipe is blocked!!! Call Exec!!;hc;g");
- return (Failed);
- }
- return (NoErr);
- }
-
-